package demo3;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-29
 * Time: 13:46
 */

public class TestDemo1 {

    public  static class Counter{
        volatile int flag = 0;
    }
    public static void main(String[] args) {
        Deque<Integer> deque = new LinkedList<>();
        Counter counter = new Counter();
        Thread t1 = new Thread(()->{
           while(counter.flag==0) {

           }
        });
        t1.start();
        Thread t2 = new Thread(()->{
           Scanner scanner = new Scanner(System.in);
            System.out.println("请输入一个数字");
            counter.flag =  scanner.nextInt();
        });
        t2.start();
    }

}
